<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
      box-sizing: border-box;
    }

    #blue {
      width: 400px;
      height: 300px;
      border: 2px solid blue;
    }

    #red {
      width: 500px;
      height: 200px;
      border: 2px solid red;
    }

    h1 {
      color: hotpink;
    }
  </style>
</head>

<body>
  <!-- 
    replaceChild(new_node,old_node) //替换 
      替换后原来的节点消失
  -->
  <div id="blue">
    <h1>阿成呀</h1>
  </div>
  <div id="red">
    <h4>强哥呀</h4>
  </div>
  <input type="button" value="点击" @click="add" id="put">
</body>
<script>
  let h1 = document.querySelector("h1");
  let h4 = document.querySelector("h4");
  let blue = document.getElementById("blue");
  let red = document.getElementById("red");
  document.getElementById("put").addEventListener("click", () => {
    blue.replaceChild(h4, h1);
  })
</script>

</html>